package com.imooc.web.wriemock;

import org.apache.commons.io.FileUtils;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

import static com.github.tomakehurst.wiremock.client.WireMock.*;

/**
 * Created by zghgchao 2018/4/19 22:18
 */
public class MockService {

    /*public static void main(String[] args) throws Exception{
        configureFor(8090);

        removeAllMappings();//把以前的配置清空，再重新设置


        mock("/order/1","01");
        mock("/order/2","02");
    }

    private static void mock(String url,String file) throws IOException {
        ClassPathResource resource = new ClassPathResource("mock/"+file+".txt");
        String content = FileUtils.readFileToString(resource.getFile(),"UTF-8");
        System.out.println(content);
        stubFor(get(urlEqualTo(url))
                .willReturn(aResponse()
                .withBody(content).withStatus(200)));//伪造一个测试桩
    }*/
}
